import React, { Component } from 'react'
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as imageActions from '@/store/actions/img';

class BlockImage extends Component {
    render() {
        let imgUrl = this.props.imgUrl.replace('{0}','3');
        return (
            <div onClick={this.openSwiper}>
                <img src={imgUrl} alt=""/>
            </div>
        )
    }

    openSwiper = () => {
        this.props.imageID && this.props.getData(1,this.props.imageID);
        this.props.changeSwiper(true);
        this.props.changeIndex(this.props.index)
    }
}

let stateMapToProps = () => {
    return {}
}

let dispatchMapToProps = (dispatch) => {
    return bindActionCreators(imageActions,dispatch)
}
export default connect(stateMapToProps,dispatchMapToProps)(BlockImage)
